﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;
using System.IO;

namespace Test
{
	// Token: 0x02000002 RID: 2
	public partial class FunPlanImport : Form
	{
        // Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
        string[] args = null;
        int argsnum = 0;
        public FunPlanImport()
		{
			this.InitializeComponent();
		}
        public FunPlanImport(string[] args)
        {
            InitializeComponent();
            this.args = args;
            argsnum = 1;
        }
        // Token: 0x06000002 RID: 2 RVA: 0x000020B0 File Offset: 0x000002B0
        private void FunPlanImport_Load(object sender, EventArgs e)
		{
			this.mydataGrid[0] = this.dataGridView1;
			this.mydataGrid[1] = this.dataGridView2;
			this.mydataGrid[2] = this.dataGridView3;
			this.mydataGrid[3] = this.dataGridView4;
			this.mydataGrid[4] = this.dataGridView5;
			this.mydataGrid[5] = this.dataGridView6;
			this.mydataGrid[6] = this.dataGridView7;
            if(argsnum!=0)
            {
                this.WindowState = FormWindowState.Minimized;
                //this.Hide();//隐藏现在这个窗口
                this.textBox1.Text = this.args[0];
                getxls();
                
                System.Environment.Exit(0);
            }


        }

		// Token: 0x06000003 RID: 3 RVA: 0x00002120 File Offset: 0x00000320
		private void btnOpen_Click(object sender, EventArgs e)
		{
			this.checkedListBox1.Items.Clear();
			this.mydt = new DataTable[7];
			int num = 0;
			OpenFileDialog openFileDialog = new OpenFileDialog();
			try
			{
				openFileDialog.Filter = "*.xls|*.XLS|*.xlsx|*.xlsx";
				bool flag = openFileDialog.ShowDialog() == DialogResult.OK;
				if (flag)
				{
					string fileName = openFileDialog.FileName;
					this.textBox1.Text = fileName;
					string text = "Provider=Microsoft.Ace.OleDb.12.0;Data Source=" + fileName + ";Extended Properties='Excel 12.0; HDR=YES; IMEX=2'";
					OleDbConnection oleDbConnection = new OleDbConnection(text);
					oleDbConnection.Open();
					DataTable oleDbSchemaTable = oleDbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
					for (int i = 0; i < oleDbSchemaTable.Rows.Count; i++)
					{
						string selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] ";
						OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
						DataSet dataSet = new DataSet();
						string text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
						oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
						bool flag2 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("方案名称");
						if (flag2)
						{
							DataTable dataTable = dataSet.Tables[0];
							for (int j = 0; j < dataTable.Rows.Count; j++)
							{
								this.checkedListBox1.Items.Add(dataTable.Rows[j][0].ToString());
								this.checkedListBox1.SetItemChecked(j, true);
							}
							dataTable.Clear();
							dataTable.Dispose();
						}
						else
						{
							bool flag3 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("集体编程");
							if (flag3)
							{
								selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
								oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
								dataSet = new DataSet();
								text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
								oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
								num++;
								this.mydt[0] = dataSet.Tables[0];
								for (int k = 0; k < this.mydt[0].Rows.Count; k++)
								{
									string text3 = this.mydt[0].Rows[k][4].ToString();
								}
								this.mydataGrid[0].DataSource = dataSet.Tables[0];
							}
							else
							{
								bool flag4 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("集体回抄");
								if (flag4)
								{
									selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
									oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
									dataSet = new DataSet();
									text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
									oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
									num++;
									this.mydt[1] = dataSet.Tables[0];
									this.mydataGrid[1].DataSource = dataSet.Tables[0];
								}
								else
								{
									bool flag5 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("单机编程");
									if (flag5)
									{
										selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
										oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
										dataSet = new DataSet();
										text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
										oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
										num++;
										this.mydt[2] = dataSet.Tables[0];
										this.mydataGrid[2].DataSource = dataSet.Tables[0];
									}
									else
									{
										bool flag6 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("单机回抄");
										if (flag6)
										{
											selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
											oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
											dataSet = new DataSet();
											text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
											oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
											num++;
											this.mydt[3] = dataSet.Tables[0];
											this.mydataGrid[3].DataSource = dataSet.Tables[0];
										}
										else
										{
											bool flag7 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("出厂设置");
											if (flag7)
											{
												selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
												oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
												dataSet = new DataSet();
												text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
												oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
												num++;
												this.mydt[4] = dataSet.Tables[0];
												this.mydataGrid[4].DataSource = dataSet.Tables[0];
											}
											else
											{
												bool flag8 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("抽检回抄");
												if (flag8)
												{
													selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
													oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
													dataSet = new DataSet();
													text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
													oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
													num++;
													this.mydt[5] = dataSet.Tables[0];
													this.mydataGrid[5].DataSource = dataSet.Tables[0];
												}
												else
												{
													bool flag9 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("抽检清零");
													if (flag9)
													{
														selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
														oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
														dataSet = new DataSet();
														text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
														oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
														num++;
														this.mydt[6] = dataSet.Tables[0];
														this.mydataGrid[6].DataSource = dataSet.Tables[0];
													}
												}
											}
										}
									}
								}
							}
						}
					}
					oleDbConnection.Dispose();
					oleDbConnection.Close();
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message.ToString(), "提示");
			}
		}

		// Token: 0x06000004 RID: 4 RVA: 0x00002A94 File Offset: 0x00000C94
		private bool blCheckColum(int index)
		{
			try
			{
				this.myColumIndex.Clear();
				this.myColumnName.Clear();
				for (int i = 0; i < this.mydt[index].Columns.Count; i++)
				{
					bool flag = this.mydt[index].Columns[i].ColumnName.ToString().Contains("数据项名称");
					if (flag)
					{
						this.myColumnName.Add("数据项名称");
						this.myColumIndex.Add(i);
					}
					bool flag2 = this.mydt[index].Columns[i].ColumnName.ToString().Contains("数据标识");
					if (flag2)
					{
						this.myColumnName.Add("数据标识");
						this.myColumIndex.Add(i);
					}
					bool flag3 = this.mydt[index].Columns[i].ColumnName.ToString().Contains("操作方式");
					if (flag3)
					{
						this.myColumnName.Add("操作方式");
						this.myColumIndex.Add(i);
					}
					bool flag4 = this.mydt[index].Columns[i].ColumnName.ToString().Contains("数据内容");
					if (flag4)
					{
						this.myColumnName.Add("数据内容");
						this.myColumIndex.Add(i);
					}
					bool flag5 = this.mydt[index].Columns[i].ColumnName.ToString().Contains("表通讯密码");
					if (flag5)
					{
						this.myColumnName.Add("表通讯密码");
						this.myColumIndex.Add(i);
					}
					bool flag6 = this.mydt[index].Columns[i].ColumnName.ToString().Contains("数据描述");
					if (flag6)
					{
						this.myColumnName.Add("数据描述");
						this.myColumIndex.Add(i);
					}
					bool flag7 = this.mydt[index].Columns[i].ColumnName.ToString().Contains("协议");
					if (flag7)
					{
						this.myColumnName.Add("协议");
						this.myColumIndex.Add(i);
					}
					bool flag8 = this.mydt[index].Columns[i].ColumnName.ToString().Contains("端口");
					if (flag8)
					{
						this.myColumnName.Add("端口");
						this.myColumIndex.Add(i);
					}
				}
				index = this.myColumnName.IndexOf("表通讯密码");
			}
			catch (Exception ex)
			{
				MessageBox.Show("捕捉到异常" + ex.Message.ToString());
			}
			return this.myColumnName.Count == 8;
		}

		// Token: 0x06000005 RID: 5 RVA: 0x00002DB0 File Offset: 0x00000FB0
		private void btnExport_Click(object sender, EventArgs e)
		{
			try
			{
				int num = 0;
				for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
				{
					bool itemChecked = this.checkedListBox1.GetItemChecked(i);
					if (itemChecked)
					{
						bool flag = this.checkedListBox1.Items[i].ToString().Contains("集体编程");
						if (flag)
						{
							this.tabControl1.SelectedIndex = 0;
							num = 0;
						}
						else
						{
							bool flag2 = this.checkedListBox1.Items[i].ToString().Contains("集体回抄");
							if (flag2)
							{
								this.tabControl1.SelectedIndex = 1;
								num = 1;
							}
							else
							{
								bool flag3 = this.checkedListBox1.Items[i].ToString().Contains("单机编程");
								if (flag3)
								{
									this.tabControl1.SelectedIndex = 2;
									num = 2;
								}
								else
								{
									bool flag4 = this.checkedListBox1.Items[i].ToString().Contains("单机回抄");
									if (flag4)
									{
										this.tabControl1.SelectedIndex = 3;
										num = 3;
									}
									else
									{
										bool flag5 = this.checkedListBox1.Items[i].ToString().Contains("出厂设置");
										if (flag5)
										{
											this.tabControl1.SelectedIndex = 4;
											num = 4;
										}
										else
										{
											bool flag6 = this.checkedListBox1.Items[i].ToString().Contains("抽检回抄");
											if (flag6)
											{
												this.tabControl1.SelectedIndex = 5;
												num = 5;
											}
											else
											{
												bool flag7 = this.checkedListBox1.Items[i].ToString().Contains("抽检清零");
												if (flag7)
												{
													this.tabControl1.SelectedIndex = 6;
													num = 6;
												}
											}
										}
									}
								}
							}
						}
						bool flag8 = this.mydataGrid[num].Rows.Count != 0;
						if (flag8)
						{
							bool flag9 = this.blCheckColum(num);
							if (flag9)
							{
								DataTable dataTable = this.fnAddField();
                                string fileName;
                                if (checkBox1.Checked)
                                    fileName = Application.StartupPath + "\\" + this.checkedListBox1.Items[i].ToString() + ".opf";
                                else
                                    fileName = Path.GetDirectoryName(this.textBox1.Text) + "\\" + this.checkedListBox1.Items[i].ToString() + ".opf";
                                for (int j = 0; j < this.mydt[num].Rows.Count; j++)
								{
									bool flag10 = this.mydt[num].Rows[j][1].ToString().Length < 2;
									if (flag10)
									{
										break;
									}
									string text = this.fnGetPort(j);
									string text2 = this.fnGetPassword(j);
									string text3 = this.fnGetProtocol(j);
									string[] array = new string[23];
									array[0] = "1";
									array[1] = this.checkedListBox1.Items[i].ToString();
									bool flag11 = text3 == "IEC";
									string text4;
									if (flag11)
									{
										text4 = "3";
									}
									else
									{
										text4 = "5";
									}
									array[2] = text4;
									int num2 = this.myColumnName.IndexOf("数据标识");
									num2 = this.myColumIndex[num2];
									array[3] = this.mydt[num].Rows[j][num2].ToString();
									num2 = this.myColumnName.IndexOf("操作方式");
									num2 = this.myColumIndex[num2];
									array[4] = this.mydt[num].Rows[j][num2].ToString();
									string text5 = "";
									bool flag12 = text3 == "DLMS";
									if (flag12)
									{
										bool flag13 = array[4] == "W";
										if (flag13)
										{
											text5 = "57";
										}
										else
										{
											bool flag14 = array[4] == "Z";
											if (flag14)
											{
												text5 = "5A";
											}
										}
									}
									array[5] = text5;
									array[6] = "";
									array[7] = "";
									array[8] = text2;
									array[9] = "";
									array[10] = text3;
									array[11] = (j + 1).ToString();
									array[12] = "";
									array[13] = "";
									num2 = this.myColumnName.IndexOf("数据内容");
									num2 = this.myColumIndex[num2];
									array[14] = this.mydt[num].Rows[j][num2].ToString();
									num2 = this.myColumnName.IndexOf("数据描述");
									num2 = this.myColumIndex[num2];
									array[15] = this.mydt[num].Rows[j][num2].ToString();
									array[16] = text;
									num2 = this.myColumnName.IndexOf("数据项名称");
									num2 = this.myColumIndex[num2];
									array[17] = this.mydt[num].Rows[j][num2].ToString();
									array[18] = "0";
									array[19] = "999";
									array[20] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
									array[21] = text3;
									array[22] = "0";
									DataTable dataTable2 = dataTable;
									object[] values = array;
									dataTable2.LoadDataRow(values, true);
								}
								dataTable.WriteXml(fileName);
							}
							else
							{
								MessageBox.Show("Excel数据表对应的数据列不符合文档格式要求", "提示");
							}
						}
					}
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show("出现异常" + ex.Message.ToString());
			}
		}

		// Token: 0x06000006 RID: 6 RVA: 0x00003390 File Offset: 0x00001590
		private string fnGetPassword(int row)
		{
			int selectedIndex = this.tabControl1.SelectedIndex;
			int num = this.myColumnName.IndexOf("表通讯密码");
			num = this.myColumIndex[num];
			bool flag = this.mydt[selectedIndex].Rows[0][num].ToString().Trim() == "" || this.mydt[selectedIndex].Rows[0][num].ToString().Trim() == null;
			string result;
			if (flag)
			{
				result = "00000000";
			}
			else
			{
				result = this.mydt[selectedIndex].Rows[row][num].ToString();
			}
			return result;
		}

		// Token: 0x06000007 RID: 7 RVA: 0x00003458 File Offset: 0x00001658
		private string fnGetPort(int row)
		{
			int selectedIndex = this.tabControl1.SelectedIndex;
			int num = this.myColumnName.IndexOf("端口");
			num = this.myColumIndex[num];
			string text = this.mydt[selectedIndex].Rows[row][num].ToString();
			string text2 = text;
			bool flag = text2 != null;
			if (flag)
			{
				bool flag2 = text2 == "485";
				if (flag2)
				{
					return "1";
				}
				bool flag3 = text2 == "远红外";
				if (flag3)
				{
					return "2";
				}
				bool flag4 = text2 == "载波";
				if (flag4)
				{
					return "3";
				}
				bool flag5 = text2 == "ZigBee";
				if (flag5)
				{
					return "4";
				}
				bool flag6 = text2 == "近红外";
				if (flag6)
				{
					return "5";
				}
			}
			return "1";
		}

		// Token: 0x06000008 RID: 8 RVA: 0x00003554 File Offset: 0x00001754
		private string fnGetProtocol(int row)
		{
			string result = "";
			try
			{
				int selectedIndex = this.tabControl1.SelectedIndex;
				int num = this.myColumnName.IndexOf("协议");
				num = this.myColumIndex[num];
				result = this.mydt[selectedIndex].Rows[row][num].ToString();
			}
			catch
			{
			}
			return result;
		}

		// Token: 0x06000009 RID: 9 RVA: 0x000035D0 File Offset: 0x000017D0
		private DataTable fnAddField()
		{
			DataSet dataSet = new DataSet("NewDataSet");
			DataTable dataTable = new DataTable("Table");
			dataSet.Tables.Add(dataTable);
			DataColumn column = new DataColumn("MIOSchemeMgrId", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("Name", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("RuleId", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("Code", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("RWType", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("WriteCtrl", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("ReadCtrl", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("Level", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("Password", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("Description", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("RuleName", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("CodeID", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("Format", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("Unit", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("Data", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("DataExplain", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("Port", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("Explain", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("TimeDifference", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("OperatorId", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("InDate", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("Sub_Name", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			column = new DataColumn("isChecked", Type.GetType("System.String"));
			dataTable.Columns.Add(column);
			return dataTable;
		}

		// Token: 0x0600000A RID: 10 RVA: 0x00003914 File Offset: 0x00001B14
		private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
		{
			SolidBrush brush = new SolidBrush(this.dataGridView1.RowHeadersDefaultCellStyle.ForeColor);
			e.Graphics.DrawString((e.RowIndex + 1).ToString(CultureInfo.CurrentUICulture), this.dataGridView1.DefaultCellStyle.Font, brush, (float)(e.RowBounds.Location.X + 20), (float)(e.RowBounds.Location.Y + 4));
		}

		// Token: 0x0600000B RID: 11 RVA: 0x000039A0 File Offset: 0x00001BA0
		private void dataGridView2_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
		{
			SolidBrush brush = new SolidBrush(this.dataGridView1.RowHeadersDefaultCellStyle.ForeColor);
			e.Graphics.DrawString((e.RowIndex + 1).ToString(CultureInfo.CurrentUICulture), this.dataGridView1.DefaultCellStyle.Font, brush, (float)(e.RowBounds.Location.X + 20), (float)(e.RowBounds.Location.Y + 4));
		}

		// Token: 0x0600000C RID: 12 RVA: 0x00003A2C File Offset: 0x00001C2C
		private void dataGridView3_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
		{
			SolidBrush brush = new SolidBrush(this.dataGridView1.RowHeadersDefaultCellStyle.ForeColor);
			e.Graphics.DrawString((e.RowIndex + 1).ToString(CultureInfo.CurrentUICulture), this.dataGridView1.DefaultCellStyle.Font, brush, (float)(e.RowBounds.Location.X + 20), (float)(e.RowBounds.Location.Y + 4));
		}

		// Token: 0x0600000D RID: 13 RVA: 0x00003AB8 File Offset: 0x00001CB8
		private void dataGridView4_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
		{
			SolidBrush brush = new SolidBrush(this.dataGridView1.RowHeadersDefaultCellStyle.ForeColor);
			e.Graphics.DrawString((e.RowIndex + 1).ToString(CultureInfo.CurrentUICulture), this.dataGridView1.DefaultCellStyle.Font, brush, (float)(e.RowBounds.Location.X + 20), (float)(e.RowBounds.Location.Y + 4));
		}

		// Token: 0x0600000E RID: 14 RVA: 0x00003B44 File Offset: 0x00001D44
		private void dataGridView5_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
		{
			SolidBrush brush = new SolidBrush(this.dataGridView1.RowHeadersDefaultCellStyle.ForeColor);
			e.Graphics.DrawString((e.RowIndex + 1).ToString(CultureInfo.CurrentUICulture), this.dataGridView1.DefaultCellStyle.Font, brush, (float)(e.RowBounds.Location.X + 20), (float)(e.RowBounds.Location.Y + 4));
		}

		// Token: 0x0600000F RID: 15 RVA: 0x00003BD0 File Offset: 0x00001DD0
		public static void ToExcel(DataTable dtSource, string strPath, string strSheetName)
		{
			OleDbConnection oleDbConnection = new OleDbConnection();
			oleDbConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='Excel 8.0;HDR=No';Data Source=\"" + strPath + "\"";
			try
			{
				oleDbConnection.Open();
				OleDbCommand oleDbCommand = new OleDbCommand();
				oleDbCommand.Connection = oleDbConnection;
				string text;
				try
				{
					text = "drop table [" + strSheetName + "]";
					oleDbCommand.CommandText = text;
					oleDbCommand.ExecuteNonQuery();
				}
				catch
				{
				}
				text = "create Table [" + strSheetName + "](";
				foreach (object obj in dtSource.Columns)
				{
					DataColumn dataColumn = (DataColumn)obj;
					text = text + "[" + dataColumn.ColumnName + "] memo,";
				}
				text = text.Trim().Substring(0, text.Length - 1);
				text += ")";
				oleDbCommand.CommandText = text;
				oleDbCommand.ExecuteNonQuery();
				foreach (object obj2 in dtSource.Rows)
				{
					DataRow dataRow = (DataRow)obj2;
					bool flag = dataRow.RowState != DataRowState.Deleted;
					if (flag)
					{
						text = "insert into [" + strSheetName + "] values(";
						foreach (object obj3 in dtSource.Columns)
						{
							DataColumn dataColumn2 = (DataColumn)obj3;
							text = text + "'" + dataRow[dataColumn2.ColumnName].ToString().Trim().Replace("'", "") + "',";
						}
						text = text.Substring(0, text.Length - 1);
						text += ")";
						oleDbCommand.CommandText = text;
						oleDbCommand.ExecuteNonQuery();
					}
				}
				oleDbConnection.Close();
			}
			catch (Exception ex)
			{
				throw ex;
			}
			finally
			{
				oleDbConnection.Close();
			}
		}

		// Token: 0x04000001 RID: 1
		private DataGridView[] mydataGrid = new DataGridView[7];

		// Token: 0x04000002 RID: 2
		private DataTable[] mydt = new DataTable[7];

		// Token: 0x04000003 RID: 3
		private TabPage[] myPage = new TabPage[7];

		// Token: 0x04000004 RID: 4
		private List<int> myColumIndex = new List<int>();

		// Token: 0x04000005 RID: 5
		private List<string> myColumnName = new List<string>();

        private void textBox1_DragDrop(object sender, DragEventArgs e)
        {
            textBox1.Text = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
            int num = 0;
            try
            {
                if (true)
                {
                    string fileName = textBox1.Text;
                    this.textBox1.Text = fileName;
                    string text = "Provider=Microsoft.Ace.OleDb.12.0;Data Source=" + fileName + ";Extended Properties='Excel 12.0; HDR=YES; IMEX=2'";
                    OleDbConnection oleDbConnection = new OleDbConnection(text);
                    oleDbConnection.Open();
                    DataTable oleDbSchemaTable = oleDbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                    for (int i = 0; i < oleDbSchemaTable.Rows.Count; i++)
                    {
                        string selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] ";
                        OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                        DataSet dataSet = new DataSet();
                        string text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                        oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                        bool flag2 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("方案名称");
                        if (flag2)
                        {
                            DataTable dataTable = dataSet.Tables[0];
                            for (int j = 0; j < dataTable.Rows.Count; j++)
                            {
                                this.checkedListBox1.Items.Add(dataTable.Rows[j][0].ToString());
                                this.checkedListBox1.SetItemChecked(j, true);
                            }
                            dataTable.Clear();
                            dataTable.Dispose();
                        }
                        else
                        {
                            bool flag3 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("集体编程");
                            if (flag3)
                            {
                                selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                dataSet = new DataSet();
                                text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                num++;
                                this.mydt[0] = dataSet.Tables[0];
                                for (int k = 0; k < this.mydt[0].Rows.Count; k++)
                                {
                                    string text3 = this.mydt[0].Rows[k][4].ToString();
                                }
                                this.mydataGrid[0].DataSource = dataSet.Tables[0];
                            }
                            else
                            {
                                bool flag4 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("集体回抄");
                                if (flag4)
                                {
                                    selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                    oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                    dataSet = new DataSet();
                                    text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                    oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                    num++;
                                    this.mydt[1] = dataSet.Tables[0];
                                    this.mydataGrid[1].DataSource = dataSet.Tables[0];
                                }
                                else
                                {
                                    bool flag5 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("单机编程");
                                    if (flag5)
                                    {
                                        selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                        oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                        dataSet = new DataSet();
                                        text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                        oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                        num++;
                                        this.mydt[2] = dataSet.Tables[0];
                                        this.mydataGrid[2].DataSource = dataSet.Tables[0];
                                    }
                                    else
                                    {
                                        bool flag6 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("单机回抄");
                                        if (flag6)
                                        {
                                            selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                            oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                            dataSet = new DataSet();
                                            text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                            oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                            num++;
                                            this.mydt[3] = dataSet.Tables[0];
                                            this.mydataGrid[3].DataSource = dataSet.Tables[0];
                                        }
                                        else
                                        {
                                            bool flag7 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("出厂设置");
                                            if (flag7)
                                            {
                                                selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                                oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                                dataSet = new DataSet();
                                                text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                                oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                                num++;
                                                this.mydt[4] = dataSet.Tables[0];
                                                this.mydataGrid[4].DataSource = dataSet.Tables[0];
                                            }
                                            else
                                            {
                                                bool flag8 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("抽检回抄");
                                                if (flag8)
                                                {
                                                    selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                                    oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                                    dataSet = new DataSet();
                                                    text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                                    oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                                    num++;
                                                    this.mydt[5] = dataSet.Tables[0];
                                                    this.mydataGrid[5].DataSource = dataSet.Tables[0];
                                                }
                                                else
                                                {
                                                    bool flag9 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("抽检清零");
                                                    if (flag9)
                                                    {
                                                        selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                                        oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                                        dataSet = new DataSet();
                                                        text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                                        oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                                        num++;
                                                        this.mydt[6] = dataSet.Tables[0];
                                                        this.mydataGrid[6].DataSource = dataSet.Tables[0];
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    btnExport.PerformClick();
                    oleDbConnection.Dispose();
                    oleDbConnection.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "提示");
            }
        }
        private void textBox1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.Link;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }




        private void getxls()
        {
            int num = 0;
            try
            {
                if (true)
                {
                    string fileName = textBox1.Text;
                    this.textBox1.Text = fileName;
                    string text = "Provider=Microsoft.Ace.OleDb.12.0;Data Source=" + fileName + ";Extended Properties='Excel 12.0; HDR=YES; IMEX=2'";
                    OleDbConnection oleDbConnection = new OleDbConnection(text);
                    oleDbConnection.Open();
                    DataTable oleDbSchemaTable = oleDbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                    for (int i = 0; i < oleDbSchemaTable.Rows.Count; i++)
                    {
                        string selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] ";
                        OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                        DataSet dataSet = new DataSet();
                        string text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                        oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                        bool flag2 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("方案名称");
                        if (flag2)
                        {
                            DataTable dataTable = dataSet.Tables[0];
                            for (int j = 0; j < dataTable.Rows.Count; j++)
                            {
                                this.checkedListBox1.Items.Add(dataTable.Rows[j][0].ToString());
                                this.checkedListBox1.SetItemChecked(j, true);
                            }
                            dataTable.Clear();
                            dataTable.Dispose();
                        }
                        else
                        {
                            bool flag3 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("集体编程");
                            if (flag3)
                            {
                                selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                dataSet = new DataSet();
                                text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                num++;
                                this.mydt[0] = dataSet.Tables[0];
                                for (int k = 0; k < this.mydt[0].Rows.Count; k++)
                                {
                                    string text3 = this.mydt[0].Rows[k][4].ToString();
                                }
                                this.mydataGrid[0].DataSource = dataSet.Tables[0];
                            }
                            else
                            {
                                bool flag4 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("集体回抄");
                                if (flag4)
                                {
                                    selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                    oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                    dataSet = new DataSet();
                                    text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                    oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                    num++;
                                    this.mydt[1] = dataSet.Tables[0];
                                    this.mydataGrid[1].DataSource = dataSet.Tables[0];
                                }
                                else
                                {
                                    bool flag5 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("单机编程");
                                    if (flag5)
                                    {
                                        selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                        oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                        dataSet = new DataSet();
                                        text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                        oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                        num++;
                                        this.mydt[2] = dataSet.Tables[0];
                                        this.mydataGrid[2].DataSource = dataSet.Tables[0];
                                    }
                                    else
                                    {
                                        bool flag6 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("单机回抄");
                                        if (flag6)
                                        {
                                            selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                            oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                            dataSet = new DataSet();
                                            text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                            oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                            num++;
                                            this.mydt[3] = dataSet.Tables[0];
                                            this.mydataGrid[3].DataSource = dataSet.Tables[0];
                                        }
                                        else
                                        {
                                            bool flag7 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("出厂设置");
                                            if (flag7)
                                            {
                                                selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                                oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                                dataSet = new DataSet();
                                                text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                                oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                                num++;
                                                this.mydt[4] = dataSet.Tables[0];
                                                this.mydataGrid[4].DataSource = dataSet.Tables[0];
                                            }
                                            else
                                            {
                                                bool flag8 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("抽检回抄");
                                                if (flag8)
                                                {
                                                    selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                                    oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                                    dataSet = new DataSet();
                                                    text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                                    oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                                    num++;
                                                    this.mydt[5] = dataSet.Tables[0];
                                                    this.mydataGrid[5].DataSource = dataSet.Tables[0];
                                                }
                                                else
                                                {
                                                    bool flag9 = oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim().Contains("抽检清零");
                                                    if (flag9)
                                                    {
                                                        selectCommandText = "select * from [" + oleDbSchemaTable.Rows[i]["table_name"].ToString().Trim() + "A:I100] where 数据标识<>''";
                                                        oleDbDataAdapter = new OleDbDataAdapter(selectCommandText, text);
                                                        dataSet = new DataSet();
                                                        text2 = oleDbSchemaTable.Rows[i]["table_name"].ToString();
                                                        oleDbDataAdapter.Fill(dataSet, oleDbSchemaTable.Rows[i]["table_name"].ToString());
                                                        num++;
                                                        this.mydt[6] = dataSet.Tables[0];
                                                        this.mydataGrid[6].DataSource = dataSet.Tables[0];
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    btnExport.PerformClick();
                    oleDbConnection.Dispose();
                    oleDbConnection.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "提示");
            }
        }
    }
}
